package com.wyw.core.config.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class CommDictDto implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3349336663084797392L;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public List<CommDictOption> getOptions() {
		return options;
	}
	public void setOptions(List<CommDictOption> options) {
		this.options = options;
	}
	public String id;
	public String name;
	public List<CommDictOption> options;
	public String queryDictTextByCode(String code){
		for(CommDictOption op:options){
			if(op.getCode().equals(code)){
				return op.getText();
			}
		}
		return null;
	}
	
	public CommDictOption queryDictOption(String code){
		for(CommDictOption op:options){
			if(op.getCode().equals(code)){
				return op;
			}
		}
		return null;
	}
	
	public List queryDictInOptions(String inOptions){
		List inOptionList = new ArrayList();
		for(CommDictOption op:options){
			if(inOptions.contains(op.getCode())){
				inOptionList.add(op);
			}
		}
		
		if(inOptionList.size()>0){
			return inOptionList ;
		}
		
		return null; 
	}
	
	public List queryDictNotInOptions(String notInOptions){
		List notInOptionList = new ArrayList();
		for(CommDictOption op:options){
			if( ! notInOptions.contains(op.getCode())){
				notInOptionList.add(op);
			}
		}
		
		if(notInOptionList.size()>0){
			return notInOptionList ;
		}
		
		return null; 
	}
}
